<template>
  <div class="sub-sort">
    <div class="sort">
      <!-- publishTime(最新)，orderNum(人气)，price(价格)， evaluateNum(评论) -->
      <a
        href="javascript:;"
        @click="changeSort('publishTime')"
        :class="{ active: subType === 'publishTime' }"
        >默认排序</a
      >
      <a
        href="javascript:;"
        @click="changeSort('orderNum')"
        :class="{ active: subType === 'orderNum' }"
        >最新商品</a
      >
      <a
        href="javascript:;"
        @click="changeSort('price')"
        :class="{ active: subType === 'price' }"
        >最高人气</a
      >
      <a
        href="javascript:;"
        @click="changeSort('evaluateNum')"
        :class="{ active: subType === 'evaluateNum' }"
        >评论最多</a
      >
    </div>
  </div>
</template>
<script>
import { ref } from 'vue'
export default {
  name: 'SubSort',
  setup () {
    const subType = ref('')
    function changeSort (subsort) {
      subType.value = subsort
    }
    return {
      subType,
      changeSort
    }
  }
}
</script>
<style scoped lang='less'>
.sub-sort {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .sort {
    display: flex;
    a {
      height: 30px;
      line-height: 28px;
      border: 1px solid #e4e4e4;
      padding: 0 20px;
      margin-right: 20px;
      color: #999;
      border-radius: 2px;
      position: relative;
      transition: all 0.3s;
      &.active {
        background: @xtxColor;
        border-color: @xtxColor;
        color: #fff;
      }
      .arrow {
        position: absolute;
        border: 5px solid transparent;
        right: 8px;
        &.up {
          top: 3px;
          border-bottom-color: #bbb;
          &.active {
            border-bottom-color: @xtxColor;
          }
        }
        &.down {
          top: 15px;
          border-top-color: #bbb;
          &.active {
            border-top-color: @xtxColor;
          }
        }
      }
    }
  }
  .check {
    .xtx-checkbox {
      margin-left: 20px;
      color: #999;
    }
  }
}
</style>
